from dataset.mnist import load_mnist
from common.deep_convnet import DeepConvNet
from common.trainer import Trainer

# 0.读入MNIST数据
(x_train, t_train), (x_test, t_test) = load_mnist(flatten=False)

# 减少学习数据
# x_train = x_train[:60000]
# t_train = t_train[:60000]

# 设置是否使用Dropout及比例
max_epochs = 10

network = DeepConvNet()
trainer = Trainer(network, x_train, t_train, x_test, t_test,
                  epochs=max_epochs, mini_batch_size=100,
                  optimizer='Adam', optimizer_param={'lr': 0.001},
                  evaluate_sample_num_per_epoch=1000)

# 开始训练
trainer.train()
# 保存训练结果
network.save_params("deep_convnet_params.pkl")
print("Saved Network Parameters!")